import {User} from "@/mysql/user"

const Sequelize = require('sequelize')
// 连接mysql
const sequelize = new Sequelize('node_data', 'root', '', {
    host: 'localhost',
    dialect: 'mysql',
    operatorsAliases: false,
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    },
    define: {
        charset: 'utf8',
        dialectOptions: {
            collate: 'utf8_general_ci'
        },
    },
    timezone: '+08:00' //东八时区

})
// 测试数据库是否成功连接
sequelize
    .authenticate()
    .then(() => {
        console.log('数据库已经正常连接')
    })
    .catch(err => {
        console.error('连接mysql,失败原因如下:', err)
    })

module.exports.sequelize = sequelize
